import request from '@/utils/request';
import {AxiosPromise} from 'axios';
import {ParkProdCategoryVO, ParkProdCategoryForm, ParkProdCategoryQuery} from '@/api/park/parkProdCategory/types';

/**
 * 查询产品分类列表
 * @param query
 * @returns {*}
 */

export const listParkProdCategory = (query?: ParkProdCategoryQuery): AxiosPromise<ParkProdCategoryVO[]> => {
  return request({
    url: '/park/parkProdCategory/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询产品分类详细
 * @param categoryId
 */
export const getParkProdCategory = (categoryId: string | number): AxiosPromise<ParkProdCategoryVO> => {
  return request({
    url: '/park/parkProdCategory/' + categoryId,
    method: 'get'
  });
};

/**
 * 新增产品分类
 * @param data
 */
export const addParkProdCategory = (data: ParkProdCategoryForm) => {
  return request({
    url: '/park/parkProdCategory',
    method: 'post',
    data: data
  });
};

/**
 * 修改产品分类
 * @param data
 */
export const updateParkProdCategory = (data: ParkProdCategoryForm) => {
  return request({
    url: '/park/parkProdCategory',
    method: 'put',
    data: data
  });
};

/**
 * 删除产品分类
 * @param categoryId
 */
export const delParkProdCategory = (categoryId: string | number | Array<string | number>) => {
  return request({
    url: '/park/parkProdCategory/' + categoryId,
    method: 'delete'
  });
};

/**
 * 状态修改
 * @param categoryId
 * @param status
 */
export const changeStatus = (categoryId: number | string, status: string) => {
  const data = {
    categoryId,
    status
  };
  return request({
    url: '/park/parkProdCategory/changeStatus',
    method: 'put',
    data: data
  });
};
